import 'package:flutter/material.dart';

class AppTheme {
  // 主要颜色
  static const Color primaryColor = Color(0xFF5E6CF2);
  static const Color secondaryColor = Color(0xFF8F94FB);
  static const Color accentColor = Color(0xFF7ED6E3);
  
  // 文本颜色
  static const Color textPrimaryColor = Color(0xFF232751);
  static const Color textSecondaryColor = Color(0xFF6F7285);
  static const Color textLightColor = Color(0xFFB5B9C8);
  
  // 背景颜色
  static const Color scaffoldColor = Color(0xFFF8F9FE);
  static const Color cardColor = Colors.white;
  
  // 特殊颜色
  static const Color successColor = Color(0xFF7FE09C);
  static const Color warningColor = Color(0xFFFFD166);
  static const Color errorColor = Color(0xFFEF8A8A);
  static const Color infoColor = Color(0xFF8C92E5);
  
  // 边框和阴影
  static BorderRadius defaultBorderRadius = BorderRadius.circular(16.0);
  static BorderRadius buttonBorderRadius = BorderRadius.circular(28.0);
  static BorderRadius chipBorderRadius = BorderRadius.circular(25.0);
  
  static List<BoxShadow> defaultShadow = [
    BoxShadow(
      color: Colors.black.withOpacity(0.05),
      blurRadius: 10,
      offset: const Offset(0, 4),
    ),
  ];
  
  static List<BoxShadow> elevatedShadow = [
    BoxShadow(
      color: primaryColor.withOpacity(0.25),
      blurRadius: 15,
      offset: const Offset(0, 8),
    ),
  ];
  
  // 间距
  static const double paddingXS = 4.0;
  static const double paddingS = 8.0;
  static const double paddingM = 16.0;
  static const double paddingL = 24.0;
  static const double paddingXL = 32.0;
  
  // 字体大小
  static const double fontSizeXS = 10.0;
  static const double fontSizeS = 12.0;
  static const double fontSizeM = 14.0;
  static const double fontSizeL = 16.0;
  static const double fontSizeXL = 18.0;
  static const double fontSizeXXL = 22.0;
  static const double fontSizeTitle = 28.0;
  
  // 应用主题
  static ThemeData lightTheme = ThemeData(
    primaryColor: primaryColor,
    scaffoldBackgroundColor: scaffoldColor,
    colorScheme: ColorScheme.fromSeed(
      seedColor: primaryColor,
      primary: primaryColor,
      secondary: secondaryColor,
    ),
    fontFamily: 'Poppins',
    textTheme: _buildTextTheme(),
    cardTheme: CardTheme(
      color: cardColor,
      elevation: 0,
      shape: RoundedRectangleBorder(
        borderRadius: defaultBorderRadius,
      ),
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        backgroundColor: primaryColor,
        foregroundColor: Colors.white,
        elevation: 0,
        padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
        shape: RoundedRectangleBorder(borderRadius: buttonBorderRadius),
      ),
    ),
    textButtonTheme: TextButtonThemeData(
      style: TextButton.styleFrom(
        foregroundColor: primaryColor,
        padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
      ),
    ),
    inputDecorationTheme: InputDecorationTheme(
      filled: true,
      fillColor: Colors.white,
      contentPadding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 16.0),
      border: OutlineInputBorder(
        borderRadius: defaultBorderRadius,
        borderSide: BorderSide.none,
      ),
      enabledBorder: OutlineInputBorder(
        borderRadius: defaultBorderRadius,
        borderSide: BorderSide.none,
      ),
      focusedBorder: OutlineInputBorder(
        borderRadius: defaultBorderRadius,
        borderSide: const BorderSide(color: primaryColor, width: 1.5),
      ),
      hintStyle: TextStyle(color: textLightColor, fontSize: fontSizeM),
    ),
    bottomNavigationBarTheme: const BottomNavigationBarThemeData(
      backgroundColor: Colors.white,
      selectedItemColor: primaryColor,
      unselectedItemColor: textLightColor,
      showSelectedLabels: true,
      showUnselectedLabels: true,
      type: BottomNavigationBarType.fixed,
      elevation: 10,
    ),
    appBarTheme: const AppBarTheme(
      backgroundColor: Colors.white,
      elevation: 0,
      iconTheme: IconThemeData(color: textPrimaryColor),
      titleTextStyle: TextStyle(
        color: textPrimaryColor,
        fontSize: fontSizeXXL,
        fontWeight: FontWeight.bold,
      ),
    ),
    tabBarTheme: const TabBarTheme(
      labelColor: primaryColor,
      unselectedLabelColor: textLightColor,
      indicator: BoxDecoration(
        border: Border(
          bottom: BorderSide(color: primaryColor, width: 2.0),
        ),
      ),
    ),
    checkboxTheme: CheckboxThemeData(
      fillColor: MaterialStateProperty.resolveWith<Color>((states) {
        if (states.contains(MaterialState.selected)) {
          return primaryColor;
        }
        return Colors.transparent;
      }),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(4.0),
      ),
    ),
    radioTheme: RadioThemeData(
      fillColor: MaterialStateProperty.resolveWith<Color>((states) {
        if (states.contains(MaterialState.selected)) {
          return primaryColor;
        }
        return textLightColor;
      }),
    ),
    useMaterial3: true,
  );
  
  // 构建文本主题
  static TextTheme _buildTextTheme() {
    return const TextTheme(
      displayLarge: TextStyle(
        fontSize: 28,
        fontWeight: FontWeight.bold,
        color: textPrimaryColor,
      ),
      displayMedium: TextStyle(
        fontSize: 22,
        fontWeight: FontWeight.bold,
        color: textPrimaryColor,
      ),
      displaySmall: TextStyle(
        fontSize: 18,
        fontWeight: FontWeight.bold,
        color: textPrimaryColor,
      ),
      headlineMedium: TextStyle(
        fontSize: 16,
        fontWeight: FontWeight.bold,
        color: textPrimaryColor,
      ),
      bodyLarge: TextStyle(
        fontSize: 16,
        color: textPrimaryColor,
      ),
      bodyMedium: TextStyle(
        fontSize: 14,
        color: textPrimaryColor,
      ),
      bodySmall: TextStyle(
        fontSize: 12,
        color: textSecondaryColor,
      ),
      labelLarge: TextStyle(
        fontSize: 14,
        fontWeight: FontWeight.bold,
        color: primaryColor,
      ),
    );
  }
  
  // 任务类别颜色
  static const Map<String, Color> categoryColors = {
    'Personal': Color(0xFFF2938C),
    'Work': Color(0xFF7ED6E3),
    'Private': Color(0xFF8A85FF),
    'Meeting': Color(0xFF7FE09C),
    'Events': Color(0xFFFFD166),
  };
  
  static const Map<String, Color> categoryBgColors = {
    'Personal': Color(0xFFFFEBE5),
    'Work': Color(0xFFE8F8FA),
    'Private': Color(0xFFF0F1FF),
    'Meeting': Color(0xFFEFFFF5),
    'Events': Color(0xFFFFF8E1),
  };
  
  // 优先级颜色
  static const Map<int, Color> priorityColors = {
    1: Color(0xFF5E6CF2), // 普通
    2: Color(0xFFFF9D4A), // 重要
    3: Color(0xFFFF4D6D), // 紧急
  };
  
  // 标签颜色
  static const Map<String, Color> tagColors = {
    'Office': Color(0xFFE1DDFF),
    'Home': Color(0xFFFFEBE5),
    'Urgent': Color(0xFFFFDDE5),
    'Work': Color(0xFFD8F8FF),
  };
  
  static const Map<String, Color> tagTextColors = {
    'Office': Color(0xFF8A85FF),
    'Home': Color(0xFFF2938C),
    'Urgent': Color(0xFFFF4D6D),
    'Work': Color(0xFF7ED6E3),
  };
  
  // 通用装饰器
  static BoxDecoration cardDecoration = BoxDecoration(
    color: cardColor,
    borderRadius: defaultBorderRadius,
    boxShadow: defaultShadow,
  );
  
  static BoxDecoration buttonDecoration = BoxDecoration(
    color: primaryColor,
    borderRadius: buttonBorderRadius,
    boxShadow: elevatedShadow,
  );
} 